﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Drawing.Drawing2D;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;

namespace _03_GDI_不同线型线条
{
    public partial class Form1 : Form
    {

        Graphics g;
        Pen pen;
        Point point = new Point(10,10);
        Size sizeLine = new Size(0, 150);
        Size sizeOff = new Size(30, 0);

        public Form1()
        {
            InitializeComponent();
            g = this.CreateGraphics();
        }

        private void Form1_Paint(object sender, PaintEventArgs e)
        {
        }



        private void button1_Click(object sender, EventArgs e)
        {
            pen = Pens.LimeGreen;
            Button button = (Button)sender;
            point = new Point(button.Location.X, ((Button)sender).Location.Y-160);
            g.DrawLine(pen, point += new Size(button.Width / 2, 0), point + sizeLine);
        }

        private void button2_Click(object sender, EventArgs e)
        {
            pen = SystemPens.MenuText;
            Button button = (Button)sender;
            point = new Point(button.Location.X, ((Button)sender).Location.Y - 160);
            g.DrawLine(pen, point += new Size(button.Width / 2, 0), point + sizeLine);
        }

        private void button3_Click(object sender, EventArgs e)
        {
            pen = new Pen(Color.Red);
            Button button = (Button)sender;
            point = new Point(button.Location.X, ((Button)sender).Location.Y - 160);
            g.DrawLine(pen, point += new Size(button.Width / 2, 0), point + sizeLine);
        }

        private void button4_Click(object sender, EventArgs e)
        {
            pen = new Pen(Color.Red,8);
            Button button = (Button)sender;
            point = new Point(button.Location.X, ((Button)sender).Location.Y - 160);
            g.DrawLine(pen, point += new Size(button.Width / 2, 0), point + sizeLine);
        }

        private void button5_Click(object sender, EventArgs e)
        {
            pen = new Pen(Color.Red, 8);
            pen.DashStyle =DashStyle.Dash;
            Button button = (Button)sender;
            point = new Point(button.Location.X, ((Button)sender).Location.Y - 160);
            g.DrawLine(pen, point += new Size(button.Width / 2, 0), point + sizeLine);
        }

        private void button6_Click(object sender, EventArgs e)
        {
            pen = new Pen(Color.Red, 8);
            pen.DashStyle = DashStyle.Dot;
            Button button = (Button)sender;
            point = new Point(button.Location.X, ((Button)sender).Location.Y - 160);
            g.DrawLine(pen, point += new Size(button.Width / 2, 0), point + sizeLine);
        }

        private void button7_Click(object sender, EventArgs e)
        {
            pen = new Pen(Color.Red, 8);
            pen.DashStyle = DashStyle.Solid;
            pen.StartCap = LineCap.Round;
            Button button = (Button)sender;
            point = new Point(button.Location.X, ((Button)sender).Location.Y - 160);
            g.DrawLine(pen, point += new Size(button.Width / 2, 0), point + sizeLine);
        }

        private void button8_Click(object sender, EventArgs e)
        {
            pen = new Pen(Color.Red, 8);
            pen.StartCap = LineCap.Round;
            pen.EndCap = LineCap.Triangle;
            Button button = (Button)sender;
            point = new Point(button.Location.X, ((Button)sender).Location.Y - 160);
            g.DrawLine(pen, point += new Size(button.Width / 2, 0), point + sizeLine);
        }

        private void button9_Click(object sender, EventArgs e)
        {
            pen = new Pen(Color.Red, 8);
            pen.DashPattern = new float[] { 0.5f, 1f, 1.5f, 2f, 2.5f };
            pen.StartCap = LineCap.Round;
            pen.EndCap = LineCap.Triangle;
            Button button = (Button)sender;
            point = new Point(button.Location.X, ((Button)sender).Location.Y - 160);
            g.DrawLine(pen, point += new Size(button.Width / 2, 0), point + sizeLine);
        }
    }
}
